package com.example.springstudy.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**用于拦截Controller请求,具体看markdown文档*/
public class StudyInterceptor implements HandlerInterceptor {
    /**在controller方法执行之前执行，返回boolean 为true侧会执行controller的方法
     * handler 表示具体是哪一个controller类的方法来运行 可以 handler instanceof HandlerMethod 转换为HandlerMethod来使用
     * */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        return false;
    }
    /**在controller方法执行之后执行，controller如果没有执行则不会执行*/
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {

    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {

    }
}
